<?php
class Model_CommentsTree_Data
{
    /**
     * Tree data
     * 
     * @var array
     */
    protected $_data;
    
    /**
     * Count of tree data
     * 
     * @var int
     */
    protected $_count;
    
    /**
     * Ids of top items on level #1
     * 
     * @var array
     */
    protected $_topIds;
    
    /**
     * Count items left
     * 
     * @var int
     */
    protected $_countLeft;
    
    function __construct($config = array())
    {
        if ($config) {
            if (isset($config['topIds'])) {
                $this->_topIds = $config['topIds'];
            }
            if (isset($config['countLeft'])) {
                $this->_countLeft = $config['countLeft'];
            }
            if (isset($config['count'])) {
                $this->_count = $config['count'];
            }
            if (isset($config['data'])) {
                $this->_data = $config['data'];
            }
        }
    }
    
    /**
     * Set tree data
     * 
     * @param mixed $data
     * @return Model_CommentsTree_Data
     */
    function setData($data)
    {
        $this->_data = $data;
        return $this;
    }
    
    /**
     * Get tree data
     * 
     * @return mixed
     */
    function getData()
    {
        return $this->_data;
    }
    
    /**
     * Set count tree data
     * 
     * @param int $count
     * @return Model_CommentsTree_Data
     */
    function setCount($count)
    {
        $this->_count = $count;
        return $this;
    }
    
    /**
     * Get count tree data
     * 
     * @return int
     */
    function getCount()
    {
        return $this->_count;
    }
    
    /**
     * Get count tree data
     * 
     * @return int
     */
    function getCountTotal()
    {
        return $this->_count + $this->_countLeft;
    }

    /**
     * Set top ids on level #1 of tree data
     * 
     * @param array $topIds
     * @return Model_CommentsTree_Data
     */
    function setTopIds($topIds)
    {
        $this->_topIds = $topIds;
        return $this;
    }
    
    /**
     * Get top ids on level #1 of tree data
     * 
     * @return array
     */
    function getTopIds()
    {
        return $this->_topIds;
    }
    
    /**
     * Get top ids on level #1 of tree data
     * 
     * @return array
     */
    function getTopIdLast()
    {
        return (int) array_pop($this->_topIds);
    }

    /**
     * Set count left after tree data
     * 
     * @param int $count
     * @return Model_CommentsTree_Data
     */
    function setCountLeft($count)
    {
        $this->_countLeft = $count;
        return $this;
    }
    
    /**
     * Get count left after tree data
     * 
     * @return int
     */
    function getCountLeft()
    {
        return $this->_countLeft;
    }
    
}